#include "ecogo.hpp"
// EcoGo.cpp 
using EcoGo::settled;
using EcoGo::unsettled;
int main(void) {
    EcoGo::EvLoop*ev=new EcoGo::EvLoop();
    std::string buffer;
    unsigned timecnt;
    (*ev).join([&](EcoGo::EvLoop& ev,bool)->EcoGo::EcoSt {
        EcoGo::ecoin >> buffer;
        if (EcoGo::ecoin.solved()) return settled;
        else return unsettled;
    }).then([&](EcoGo::EvLoop& ev,bool flag)->EcoGo::EcoSt {
        if(!EcoGo::ecoin.solved()) {
            if(!flag) EcoGo::ecout << "EvIO<input> demo: write something.\n";
            else timecnt++;
            return unsettled;
        }
        EcoGo::ecout << "\nCosts: " << timecnt << " ics.\nInfo: " << buffer <<"\n";
        return settled;
    }).final([&]()->void {
        if(EcoGo::ecoin.solved()) {
            EcoGo::ecorr << "Demo logout.\n\n";
            !EcoGo::ecoin, buffer.clear();
        }
    }).run(EcoGo::REONCE);
    delete ev;
    return 0;
}